package source.model;

import source.model.type.*;

public class Item implements GameObject {
	
	private boolean isValid = true;
	private final GameObjectType gameObjectType = GameObjectType.ITEM;
	private final ItemType itemType;
	private static int nextId = 0;
	private final ObjectID oid;
	
	private int toChangeX = -1, toChangeY = -1;
	private boolean positionChangeFlag = false;
	
	public Item( ItemType it ) {
		oid = new ObjectID( gameObjectType.getId() + "." + nextId++ );
		itemType = it;
	}
	
	public ItemType getItemType() {
		return itemType;
	}
	
	public boolean isObstruction() {
		return itemType.obstruction();
	}
	
	/**
	 * IF Item is useable, must extend Useable interface
	 * @return
	 */
	public boolean isUseableItem() {
		return itemType.useable();
	}
	
	public boolean isTriggered() {
		return itemType.triggered();
	}
	
	public boolean isPlayerOwned() {
		return false;
	}
	
	public GameObjectType objectType() {
		return gameObjectType;
	}
	
	public boolean isValid() {
		return isValid;
	}
	
	public void invalidate() {
		isValid = false;
	}
	
	public boolean changePosition( int x, int y ) {
		this.toChangeX = x;
		this.toChangeY = y;
		return true;
	}
	
	public Position newPosition() {
		return new Position( toChangeX, toChangeY );
	}
	
	public boolean resetPositionChangedFlag() {
		positionChangeFlag = true;
		return positionChangeFlag;
	}
	
	public boolean changePositionFlag() {
		return positionChangeFlag;
	}
	
	public ObjectID objectID() {
		return oid;
	}
	
	/**
	 * View stuff all done here Brent
	 */
	public java.util.Hashtable<String, String> getViewData()
	{
		return null;
	}
	
	public String toString(){
		return itemType.getName();
	}
	
	public String msg(){
		return itemType.getMsg();
	}
}